<template>
	<view class="lookPho">
		<image :src="url" mode="" @longpress="logoTime" :class="[isIndex == 1? 'filter':'']"></image>
		<view class="longFont" v-if="isFontShow">
			长按屏幕即可查看
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
				title: '',
				isIndex: 1,
				isFontShow: true,
				zhaopianID: '',
				duration: '',
				permission:''
			}
		},

		onLoad(options) {
			if (options.url) {
				this.url = options.url
			}
			if (options.name) {
				this.title = options.name
			}
			if (options.id) {
				this.zhaopianID = options.id
			}
			if (options.permission) {
				this.permission = options.permission
			}
			uni.setNavigationBarTitle({
				title: this.title
			})
		},
		created() {
			this.lookedTime()
			this.getDestroy()
		},
		methods: {
			logoTime(e) {
				this.isIndex = 0
				this.isFontShow = false
				setTimeout(() => {
					this.isFontShow = true
					this.isIndex = 1
				}, this.duration)
			},
			previewImg(logourl) {
				let _this = this;
				let imgsArray = [];
				imgsArray[0] = logourl //在线图片
				uni.previewImage({
					current: 0,
					urls: imgsArray
				});
			},
			getDestroy() {
				console.log(this.permission,'this.permission')
				if(this.permission == '2' || this.permission == '4'){
					console.log(this.permission,'this.permission')
				setTimeout(()=>{
					this.$u.post('/user/album/file/burned', {id:this.zhaopianID}).then(res => {
							if (res) {
								if(res.dat.result){
									
								}
							console.log(res,'res')
							}
						})
						.catch((res) => {
							console.log(res.message)
						})
				},this.duration)
				}
				if(this.permission == '3' || this.permission == '4'){
					this.$u.get('/user/album/file/pay',{id:this.zhaopianID}).then(res => {
							if (res.code == 200) {
								this.previewImg(res.data.url)
					
							}else {
							}
						})
						.catch((res) => {
						})
				}
			},
			lookedTime() {
				this.$u.get('/user/album/file/burned/duration').then(res => {
						if (res) {
							this.duration = res.data.duration
						}
					})
					.catch((res) => {})
			}
		}
	}
</script>

<style>
	.lookPho {
		width: 100%;
		height: 100%;
	}

	.lookPho image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.filter {
		-webkit-filter: blur(20rpx);
		/* Chrome, Opera */
		-moz-filter: blur(20rpx);
		-ms-filter: blur(20rpx);
		filter: blur(20rpx);
		display: block;
	}

	.longFont {
		position: absolute;
		top: 40%;
		left: 50%;
		transform: translate(-50%, -50%);
		font-size: 36rpx;
		font-weight: bold;
		color: rgba(255, 255, 255, 1);
	}
</style>
